//
//  SettingPushCell.m
//  Ufan
//
//  Created by yangqingluo on 16/1/15.
//  Copyright © 2016年 yangqingluo. All rights reserved.
//

#import "SettingPushCell.h"

@interface SettingPushCell()

@property (strong, nonatomic) UISwitch *switchButton;

@end

@implementation SettingPushCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.textLabel.font = [UIFont systemFontOfSize:16.0];
        self.textLabel.textColor = [UIColor blackColor];
        
        self.switchButton = [UISwitch new];
        [self.contentView addSubview:self.switchButton];
        [self.switchButton addTarget:self action:@selector(switchButtonClick:) forControlEvents:UIControlEventValueChanged];
    }
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    
    self.switchButton.center = CGPointMake(self.width - 15 - 0.5 * self.switchButton.width, self.textLabel.center.y);
    [self.switchButton setOn:[AppPublic shareInstanceApp].queryPush];
}

- (void)switchButtonClick:(UISwitch *)button{
    [[AppPublic shareInstanceApp] setPush:button.isOn];
}

@end
